import Vue from 'vue'
import Vuex from 'vuex'
Vue.use(Vuex)
import createPersistedState from 'vuex-persistedstate'

import login from './modules/login.js'

export default new Vuex.Store({
	state: {},
	mutations: {},
	actions: {},
	getters: {},
	modules: {
		login
	},
	plugins: [createPersistedState({
		// vuex-persistedstate默认配置是使用 window.localStorage。必须改成uni 否则在App和小程序会报错
		storage: {
			getItem: key => uni.getStorageSync(key),
			setItem: (key, value) => uni.setStorageSync(key,value),
			removeItem: key => uni.removeStorageSync(key)
		},
		paths : ['login']
	})]
})